package gui;

import java.awt.Color;
import java.awt.Component;
import java.util.List;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author Mariano Zapata
 */
public class RenderTablaAgenda extends DefaultTableCellRenderer {

    private DialogoAgenda da;

    public RenderTablaAgenda(DialogoAgenda da) {
        super();
        this.da= da;
    }

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
            int row, int col) {
        Component c= super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
        List<Integer> diasImportantes= da.getDiasImportantes();
        int numero= -1;
        String valorCelda= (String) value;
        if (!valorCelda.isEmpty())
            numero= Integer.parseInt(valorCelda);
        if (!isSelected)
        {
            if (diasImportantes != null && diasImportantes.contains(numero))
                c.setBackground(Color.red);
            else
                c.setBackground(Color.white);
        }
        return c;
    }
}
